<template>
  <div class="tabs">
    <div class="tabs-title">
      <span>{{ translate('物资出入库列表') }}</span>
    </div>
    <el-table :data="listseenarr" style="width: 100%">
      <el-table-column
        :label="translate('时间')"
        prop="DateName"
        width="180"
      />
      <el-table-column :label="translate('入库数量')" prop="InQty" />
      <el-table-column :label="translate('出库数量')" prop="OuQty" />
    </el-table>
  </div>
</template>

<script>
  import { translate } from '@/i18n'
  import { getpageASIO } from '@/api/form'
  export default defineComponent({
    props: {
      searchtime: {
        type: Array,
        default: () => {
          return []
        },
      },
      searchinfo: {
        type: String,
        default: '',
      },
      searchinfo1: {
        type: String,
        default: '',
      },
      datetype: {
        type: String,
        default: '',
      },
      sign: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        tableData: [],
        time: this.searchtime,
        bgyear: this.searchinfo,
        endyear: this.searchinfo1,
        listseenarr: [],
        datetypes: this.datetype,
        signs: this.sign,
        itemcode: ''
      }
    },
    watch: {
      searchtime(val) {
        console.log(val+'112')
        if(val) {
          this.time = val
          // this.billchartdatas()
        }
      },
      searchinfo(val) {
        if(val) {
        console.log(val)
          this.bgyear = val
          if(this.bgyear && this.endyear && this.endyear*1 > this.bgyear*1){
            // this.billchartdatas()
          }else {
            this.$message({
              message: '结束年份要大于起始年份',
              type: 'warning',
            })
          }
        }
      },
      searchinfo1(val) {
        if(val) {
          this.endyear = val
          if(this.bgyear && this.endyear && this.endyear*1 > this.bgyear*1){
            // this.billchartdatas()
          }else {
            this.$message({
              message: '结束年份要大于起始年份',
              type: 'warning',
            })
          }
        }
      },
      sign(val) {
        console.log(val)
        if(val) {
          this.signs = val
          this.billchartdatas()
        }
      },
    },
    created() {
      this.billchartdatas()
    },
    methods: {
      translate(row) {
        return translate(row)
      },
      childMethod(val) {
        this.billchartdatas(val)
        console.log(val)
      },
      async billchartdatas(val) {
        if(val){
          this.datetypes = val.dateType
        }
            const params = {
            dateType: this.datetypes,
            beginDate: this.datetypes ==='YE' ? this.bgyear :  this.time[0],
            endDate: this.datetypes ==='YE' ? this.endyear :  this.time[1],
            sign:this.signs === '入库(+)'? '+':this.signs === '出库(-)' ? '-':'',
            itemCode: val ? val.itemcode : '',
            whUnit: val ? val.whUnit:'',
           }
          const data = await getpageASIO(params)
          if(data.code === '200') {
            this.listseenarr = data.data.rows
            console.log(this.listseenarr)
          }


      },
    },
  })
</script>

<style lang="scss" scoped>
  .tabs {
    background: #ffffff;
    padding: 20px;
    .tabs-title {
      position: relative;
      color: #000;
      font-weight: 600;
      padding-bottom: 15px;
      font-size: 14px;

      .more {
        position: absolute;
        top: 0;
        right: 0;
        cursor: pointer;
      }
      .count {
        display: inline-block;
        border: 1px solid #f31434;
        color: red;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        margin-left: 5px;
        text-align: center;
      }
    }
  }
</style>
